#ifndef COMMANDFACTORY
#define COMMANDFACTORY

#include <map>

using std::map;

class command;
class streamingConnection;

class commandFactory {

  static commandFactory *_instance;

  commandFactory();
  commandFactory(commandFactory &);
  commandFactory * operator=(commandFactory &);
  ~commandFactory();

public:

   typedef command* (*createCommandCallback)(unsigned int, streamingConnection *connection);

private:

   typedef std::map<unsigned int, createCommandCallback> commandsMap;

public:

  static commandFactory &instance();

  bool registerCommand(unsigned int commnadId, createCommandCallback createFn);
  bool unregisterCommand(unsigned int commandId);
  command* createCommand(unsigned int commandId, streamingConnection *connection);

private:

  commandsMap commands;
  commandsMap::iterator icommands;
};

#endif